
<template>
  <el-menu
    :default-active="menuActive"
    :collapse="isCollapse"
    :style="{ width: !isCollapse ? '230px' : '66px' }"
    active-text-color="#ffd04b"
    background-color="#545c64"
    class="aside-container"
    text-color="#fff"
    @open="handleOpen"
    @close="handleClose"
  >
    <p class="logo">{{isCollapse ? 'DIDI' : 'DIDI陪诊'}}</p>
    <TreeMenu :menuData="menuData" :index="1" />
  </el-menu>
</template>


<script setup>
import { useRouter } from 'vue-router'
import TreeMenu from './treeMenu.vue'
import { reactive, computed } from 'vue'
import { useStore } from 'vuex'

const store = useStore()

const isCollapse = computed(() => store.state.menu.isCollapse)

const menuActive = computed(() => store.state.menu.menuActive)

const router = useRouter()

// const menuData = reactive(router.options.routes[0].children)
// 更改成动态路由获取的数据，而不是写死的路由表数据，路由表已注释
const menuData = computed(() => store.state.menu.routerList)

const handleOpen = (key, keyPath) => {
  console.log(key, keyPath);
};
const handleClose = (key, keyPath) => {
  console.log(key, keyPath);
};
</script>

<style scoped lang="less">
.aside-container {
  height: 100vh;

  .logo {
    font-size: 20px;
    text-align: center;
    line-height: 50px;
    color: #fff;
  }
}
</style>
